//
//  HCCRMDetailViewController.m
//  HelloCall
//
//  Created by WangYongpeng on 13-9-21.
//  Copyright (c) 2013年 HC. All rights reserved.
//

#import "HCCRMDetailViewController.h"

@interface HCCRMDetailViewController ()

@property (nonatomic, retain) HCCRMCustomInfo* customInfo;

@end

@implementation HCCRMDetailViewController

@synthesize customInfo = m_customInfo;

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    self.title = @"客户详情";
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)showCustomInfoDetail:(HCCRMCustomInfo*)customInfo
{
    self.customInfo = customInfo;
    
    NSString* text = @"单个话单查看详情内容：\n\n";
    
    text = [text stringByAppendingFormat:@"客户来电号码：%@\n",self.customInfo.customPhoneNumber];
    text = [text stringByAppendingFormat:@"联系手机：%@\n",self.customInfo.mobilePhoneNumber];
    text = [text stringByAppendingFormat:@"座机：%@\n",self.customInfo.phoneNumber];
    text = [text stringByAppendingFormat:@"联系人：%@\n",self.customInfo.contact];
    text = [text stringByAppendingFormat:@"单位：%@\n",self.customInfo.company];
    text = [text stringByAppendingFormat:@"QQ：%@\n",self.customInfo.qqNumber];
    text = [text stringByAppendingFormat:@"网站：%@\n",self.customInfo.web];
    text = [text stringByAppendingFormat:@"客户属性：%@\n",[self getCustomAttribute:self.customInfo.attribute]];
    text = [text stringByAppendingFormat:@"下次沟通时间：%d天后\n",self.customInfo.nextVisitTime];
    text = [text stringByAppendingFormat:@"沟通备忘录：%@\n",self.customInfo.Memo];
    NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy年MM月dd号 HH:mm:ss"];
    text = [text stringByAppendingFormat:@"初始沟通时间：%@\n",[dateFormatter stringFromDate:self.customInfo.initTime]];
    text = [text stringByAppendingFormat:@"来源：%@\n",[self getCallSoucre]];
    text = [text stringByAppendingFormat:@"转为潜在客户周期：%d天\n",self.customInfo.potentialCustomersTime];
    text = [text stringByAppendingFormat:@"成交周期：%d天\n",self.customInfo.transactionTime];
    text = [text stringByAppendingFormat:@"电话沟通次数：%d次\n",self.customInfo.visitCount];
    text = [text stringByAppendingFormat:@"通话总时长：%d分钟\n",self.customInfo.sumCallTime];
    text = [text stringByAppendingFormat:@"回访周期：%d天\n",self.customInfo.reVisitTime];
    
    [self setDetailText:text];
}

- (NSString*)getCustomAttribute:(ECustomAttribute)attribute
{
    NSString* text = nil;
    switch (attribute)
    {
        case ECustomAttribute_1:
        {
            text = @"客户属性1";
            break;
        }
        case ECustomAttribute_2:
        {
            text = @"客户属性2";
            break;
        }
        default:
            break;
    }
    return text;
}

- (NSString*)getCallSoucre
{
    NSString* callSoucreText = nil;
    
    switch (self.customInfo.sourceType)
    {
        case CallSourceType_allocation:
        {
            callSoucreText = @"企业分配";
            break;
        }
        case CallSourceType_spread:
        {
            callSoucreText = @"推广来源";
            break;
        }
        case CallSourceType_visit:
        {
            callSoucreText = @"定时访问";
            break;
        }
        default:
        {
            callSoucreText = @"推广来源";
            break;
        }
    }
    
    return callSoucreText;
}

@end
